package demo1;

public class Test {
    public static boolean isPalindrome(String s) {
        String s2 = s.toLowerCase();
        int front = 0;
        int last = s2.length() - 1;
        while(front < last){
            while((s2.charAt(front) < 'a' || s2.charAt(front) > 'z') && front < last){
                front++;
            }
            while((s2.charAt(last) < 'a' || s2.charAt(last) > 'z') && front < last){
                last--;
            }
            if(s2.charAt(front) != s2.charAt(last)){
                break;
            }else{
                front++;
                last--;
            }
        }

        if(front == last){
            return true;
        }
        return false;
    }
    public static int firstUniqChar(String s) {
        int index = -1;

        //创建标准数组
        char[] arr = new char[26];

        for(int i = 0; i < s.length(); i++){
            arr[s.charAt(i) - 'a']++;
        }

        for(int i = 0; i < s.length(); i++){
            if(arr[s.charAt(i) - 'a'] == 1){
                return i;
            }
        }

        return index;
    }

    public static void main1(String[] args) {
        String s = "aaaaaaaaaaaaaaaaaaaaaa";
        int ret = firstUniqChar(s);
    }

    public static void main(String[] args) {
        String s = "A man, a plan, a canal: Panama";
        boolean ret = isPalindrome(s);
    }
}
